Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a single-pass-fragment-shader path #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ammen99
Copy link
Contributor

@ammen99 ammen99 commented Feb 25, 2024

This PR aims to make it possible to optimize most of the effects which can be rendered with a single fragment shader pass. The old pipeline uses 3 passes:

  • Compute pass for the effect
  • Compute pass for the overlay engine
  • Fragment shader pass for rendering

The new render code combines all three together in a single fragment shader pass, allowing us to also make efficient use of GL scissor. By reducing the passes, we also reduce the CPU usage.

The idea of how the shaders work:

  • All of them share the same headers and the same uniforms, width, height, current_time
  • Each effect needs to provide a function, vec4 effect_color(vec2 pos) which gives the color from the effect.
  • Each overlay engine provides a function, vec4 overlay_effect(vec2 pos). It may call effect_color() to get the color of the effect, or set a color on its own. For example the none overlay effect simply returns effect_color(pos).
  • The main function is the same for all combinations, it just calls overlay_effect(pos).

The headers, effect, overlay and main function code are simply concatenated together to form a single shader which is then executed.

@ammen99
Copy link
Contributor Author

ammen99 commented Feb 25, 2024

Two things I forgot to mention:

  • The new render code currently resides alongside the old render pipeline because I was too lazy to port all the effects. But, we can just port them one by one, no need to do everything at once.

  • For example the clouds effect + rounded corners, I had a reduction of power usage from 6W to 1.2W on my Intel iGPU. CPU usage is also reduced by 20% or so. Also killown confirmed on IRC that the new implementation is visually smoother and uses less CPU.

@soreau
Copy link
Owner

soreau commented Mar 26, 2024

* The new render code currently resides alongside the old render pipeline because I was too lazy to port all the effects. But, we can just port them one by one, no need to do everything at once.

After they are all ported, we can merge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants